#include <iostream>

using namespace std;

int array_difference(int* number_array, unsigned int n);

int main() {
	unsigned int n;
	cin >> n;
	int* number_array = new int[n];
	for (unsigned int i = 0; i < n; i++) {
		cin >> *(number_array + i);
	}
	cout << array_difference(number_array, n);
	delete[] number_array;
}

int array_difference(int* number_array, unsigned int n) {
	int maximum = -5000, minimum = 5000;
	for (unsigned int i = 0; i < n; i++) {
		maximum = max(maximum, *(number_array + i));
		minimum = min(minimum, *(number_array + i));
	}
	return maximum - minimum;
}